<?php
namespace app\index\controller;

use think\Controller;
use think\Request;

class Index extends Controller
{
    public function index()
    {
        if(Request::instance()->isGet()&&!Request::instance()->isAjax())
        {
            return view();
    
        }else
        {
            header("content-type: text/html;charset=UTF-8");
            ini_set('max_execution_time', '0');
            $extra=input('post.extra');
            $url="https://mainsite-restapi.ele.me/marketing/v2/new_refer/".$extra;
            $a_tel=array('139','138','137','136','135','134','147','188','187','184','183','182','159','158','157','152','151','150','186','185','145','156','155','132','131','130','189','181','180','153','133','177');
            $this->run($url, $a_tel);
        }
    }
    function run($url,$a_tel){
        for($ii=0;$ii<5000;$ii++){
            $phone=$a_tel[rand(0,31)];
            //file_put_contents('da.txt', $phone);
            $pp=rand(1,9).rand(1,9).rand(1,9).rand(1,9);
            $phone=$phone.$pp.rand(1,9).rand(1,9).rand(1,9).rand(1,9);
    
            //file_put_contents('da2.txt', $phone);
             
            // $group_sn=substr(sha1(rand(1,10000)),0,16);
            //$sign=md5($phone);
            //     file_put_contents('sign.txt',$group_sn."/".$sign);
            //     die;
            $str=substr(sha1($phone), 0,5);
            $weixin_avatar="https://unsplash.it/400/400/?random";
            date_default_timezone_set('Asia/Shanghai');
            $a_arr=array('a','b','c','d','e','f','g','h','i','j','k','l','n','m','o','p','q','x','y','z','r','s','w');
            $b_arr=array('A','B','C','D','E','F','G','H','I','J','K','L','N','M','O','P','Q','X','Y','Z','R','S','W');
            $ttime=date('H-i-s');
            $wexin_username=$pp.$ttime;
            $ext=$a_arr[rand(0,22)];
            $unionid=$ext."_PV".$b_arr[rand(0,22)]."uIZU".rand(1,9).rand(1,9).rand(1,9)."_P".$a_arr[rand(0,22)]."R0".$b_arr[rand(0,22)]."HCH".$a_arr[rand(0,22)].$a_arr[rand(0,22)].$a_arr[rand(0,22)].$a_arr[rand(0,22)].$a_arr[rand(0,22)]."Sg";
            $suiji=rand(1,9);
            $suiji2=rand(1,9);
            $suiji3=rand(1,9);
            $suiji4=rand(1,9);
            $ccc=$suiji."EG".$b_arr[rand(0,22)]."vjqRQff".$suiji2."t-".$suiji3."K".$b_arr[rand(0,22)]."L".$a_arr[rand(0,22)]."Y".$suiji4."Cw".$b_arr[rand(0,22)]."Kw".$a_arr[rand(0,22)]."A";
            $data='{"phone":"'.$phone.'","username":"'.$wexin_username.'","avatar":"'.$weixin_avatar.'","sns_uid":"'.$ccc.'","unionid":"'.$unionid.'","sns_type":"0","ua":3}';
    
    
            $res=$this->https_request($url,$data);
    
             
    
         
             
             
        }
         
    }
    function https_request($url,$data = null){
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
        if (!empty($data)){
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        }
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }
}
